﻿namespace Example.Creational.LazyInitialization
{
    using System;
    using System.Threading;

    [Message(Value = "A message value.")]
    public sealed class Thing
    {
        private readonly Lazy<string> _message = new Lazy<string>(
            () => ((MessageAttribute)Attribute.GetCustomAttribute(typeof(Thing), typeof(MessageAttribute), false)).Value, 
            LazyThreadSafetyMode.ExecutionAndPublication);

        public string Message
        {
            get
            {
                return _message.Value;
            }
        }
    }
}